<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 - 电影票预订系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- 引入Font Awesome图标 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary-color: #9d4edd;
            --secondary-color: #5a189a;
            --accent-color: #ff6b6b;
            --dark-color: #10002b;
            --light-color: #f8f9fa;
        }
        
        body {
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            position: relative;
            overflow-x: hidden;
        }
        
        /* 电影胶片效果装饰 */
        .film-strip {
            position: absolute;
            width: 100%;
            height: 30px;
            background: repeating-linear-gradient(
                90deg,
                #000 0px,
                #000 15px,
                #333 15px,
                #333 30px
            );
            opacity: 0.3;
            z-index: 1;
        }
        
        .film-strip-top {
            top: 0;
        }
        
        .film-strip-bottom {
            bottom: 0;
        }
        
        .register-card {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
            overflow: hidden;
            max-width: 500px;
            width: 100%;
            z-index: 2;
            position: relative;
            transition: all 0.3s ease;
        }
        
        .register-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
        }
        
        .card-header {
            background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            padding: 30px 20px;
            text-align: center;
            color: white;
            position: relative;
            overflow: hidden;
        }
        
        .card-header::before {
            content: "";
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
            transform: rotate(30deg);
        }
        
        .card-header h2 {
            font-size: 2.2rem;
            font-weight: 700;
            margin: 0;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3);
            letter-spacing: 1px;
            position: relative;
        }
        
        .card-header p {
            opacity: 0.9;
            margin: 10px 0 0;
            position: relative;
        }
        
        .card-body {
            padding: 30px;
        }
        
        .form-group {
            margin-bottom: 25px;
            position: relative;
        }
        
        .form-group label {
            display: flex;
            align-items: center;
            color: var(--secondary-color);
            font-weight: 600;
            margin-bottom: 8px;
        }
        
        .form-group label i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
        }
        
        .form-control {
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            padding: 12px 15px 12px 40px;
            height: 50px;
            transition: all 0.3s ease;
            font-size: 1rem;
        }
        
        .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(157, 78, 221, 0.2);
        }
        
        .input-icon {
            position: absolute;
            left: 15px;
            top: 40px;
            color: #777;
            transition: all 0.3s ease;
        }
        
        .form-control:focus + .input-icon {
            color: var(--primary-color);
        }
        
        .btn-register {
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            border: none;
            border-radius: 8px;
            padding: 14px;
            font-size: 1.1rem;
            font-weight: 600;
            letter-spacing: 0.5px;
            box-shadow: 0 5px 15px rgba(154, 96, 212, 0.4);
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            color: white;
            width: 100%;
            margin-top: 10px;
        }
        
        .btn-register:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(154, 96, 212, 0.6);
        }
        
        .btn-register:active {
            transform: translateY(1px);
        }
        
        .btn-register::after {
            content: "";
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: rgba(255, 255, 255, 0.2);
            transform: rotate(30deg);
            transition: all 0.5s ease;
            opacity: 0;
        }
        
        .btn-register:hover::after {
            opacity: 1;
            top: -20%;
            left: -20%;
        }
        
        .login-link {
            text-align: center;
            margin-top: 25px;
            color: #666;
            font-size: 0.95rem;
        }
        
        .login-link a {
            color: var(--primary-color);
            font-weight: 600;
            text-decoration: none;
            transition: all 0.3s ease;
            position: relative;
        }
        
        .login-link a::after {
            content: '';
            position: absolute;
            width: 0;
            height: 2px;
            bottom: -2px;
            left: 0;
            background-color: var(--primary-color);
            transition: width 0.3s ease;
        }
        
        .login-link a:hover {
            color: var(--secondary-color);
        }
        
        .login-link a:hover::after {
            width: 100%;
        }
        
        .error-message {
            color: #dc3545;
            font-size: 0.85rem;
            margin-top: 6px;
            display: block;
            padding-left: 30px;
        }
        
        .password-strength {
            height: 5px;
            background: #eee;
            border-radius: 3px;
            margin-top: 8px;
            overflow: hidden;
            position: relative;
        }
        
        .password-strength::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 0;
            background: #dc3545;
            transition: width 0.3s ease;
        }
        
        .password-strength[data-strength="1"]::before {
            width: 25%;
            background: #dc3545;
        }
        
        .password-strength[data-strength="2"]::before {
            width: 50%;
            background: #ffc107;
        }
        
        .password-strength[data-strength="3"]::before {
            width: 75%;
            background: #28a745;
        }
        
        .password-strength[data-strength="4"]::before {
            width: 100%;
            background: #28a745;
        }
        
        .password-info {
            font-size: 0.8rem;
            color: #666;
            margin-top: 5px;
            padding-left: 30px;
        }
        
        .movie-icon {
            position: absolute;
            right: -20px;
            bottom: -20px;
            font-size: 8rem;
            opacity: 0.05;
            z-index: 0;
            color: var(--secondary-color);
        }
        
        @media (max-width: 576px) {
            .register-card {
                margin: 20px;
            }
            
            .card-header h2 {
                font-size: 1.8rem;
            }
            
            .card-body {
                padding: 20px;
            }
        }
    </style>
</head>
<body>
    <!-- 电影胶片装饰 -->
    <div class="film-strip film-strip-top"></div>
    <div class="film-strip film-strip-bottom"></div>
    
    <div class="register-card">
        <div class="card-header">
            <h2><i class="fas fa-ticket-alt"></i> 用户注册</h2>
            <p>加入我们，开启电影之旅</p>
        </div>
        
        {% with messages = get_flashed_messages(with_categories=true) %}
  {% if messages %}
    {% for category, message in messages %}
      <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
        {{ message }}
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
      </div>
    {% endfor %}
  {% endif %}
{% endwith %}
        <div class="card-body">
            <form method="POST">
                {{ form.hidden_tag() }}
                
                <div class="form-group">
                    <label for="username">
                        <i class="fas fa-user"></i> 用户名
                    </label>
                    <div class="position-relative">
                        <i class="fas fa-user input-icon"></i>
                        {{ form.username(class="form-control", id="username", placeholder="请输入用户名") }}
                    </div>
                    {% for error in form.username.errors %}
                        <span class="error-message">{{ error }}</span>
                    {% endfor %}
                </div>
                
                <div class="form-group">
                    <label for="email">
                        <i class="fas fa-envelope"></i> 电子邮箱
                    </label>
                    <div class="position-relative">
                        <i class="fas fa-envelope input-icon"></i>
                        {{ form.email(class="form-control", id="email", placeholder="请输入电子邮箱") }}
                    </div>
                    {% for error in form.email.errors %}
                        <span class="error-message">{{ error }}</span>
                    {% endfor %}
                </div>
                
                <div class="form-group">
                    <label for="phone">
                        <i class="fas fa-phone"></i> 手机号码
                    </label>
                    <div class="position-relative">
                        <i class="fas fa-phone input-icon"></i>
                        {{ form.phone(class="form-control", id="phone", placeholder="请输入手机号码") }}
                    </div>
                    {% for error in form.phone.errors %}
                        <span class="error-message">{{ error }}</span>
                    {% endfor %}
                </div>
                
                <div class="form-group">
                    <label for="password">
                        <i class="fas fa-lock"></i> 密码
                    </label>
                    <div class="position-relative">
                        <i class="fas fa-lock input-icon"></i>
                        {{ form.password(class="form-control", id="password", placeholder="请输入密码") }}
                    </div>
                    <div class="password-strength" id="password-strength" data-strength="0"></div>
                    <div class="password-info">
                        密码应包含至少8个字符，包括字母、数字和特殊字符
                    </div>
                    {% for error in form.password.errors %}
                        <span class="error-message">{{ error }}</span>
                    {% endfor %}
                </div>
                
                <div class="form-group">
                    <label for="confirm_password">
                        <i class="fas fa-lock"></i> 确认密码
                    </label>
                    <div class="position-relative">
                        <i class="fas fa-lock input-icon"></i>
                        {{ form.confirm_password(class="form-control", id="confirm_password", placeholder="请再次输入密码") }}
                    </div>
                    {% for error in form.confirm_password.errors %}
                        <span class="error-message">{{ error }}</span>
                    {% endfor %}
                </div>
                
                <button type="submit" class="btn btn-register">注册账号</button>
            </form>
            
            <div class="login-link">
                已有账号？<a href="{{ url_for('auth.login') }}">立即登录</a>
            </div>
        </div>
        
        <i class="fas fa-film movie-icon"></i>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        // 添加邮箱实时检查
document.getElementById('email').addEventListener('blur', function() {
    const email = this.value;
    if(email) {
        fetch(`/check-email?email=${email}`)
            .then(response => response.json())
            .then(data => {
                if(data.exists) {
                    // 显示错误信息
                    this.nextElementSibling.textContent = '该邮箱已被注册';
                }
            });
    }
});
        // 密码强度检测
        document.getElementById('password').addEventListener('input', function() {
            const password = this.value;
            const strengthBar = document.getElementById('password-strength');
            let strength = 0;
            
            if (password.length > 0) strength += 1;
            if (password.length >= 8) strength += 1;
            if (/[A-Z]/.test(password)) strength += 1;
            if (/[0-9]/.test(password)) strength += 1;
            if (/[^A-Za-z0-9]/.test(password)) strength += 1;
            
            // 限制最大强度为4
            strength = Math.min(strength, 4);
            strengthBar.setAttribute('data-strength', strength);
        });
        
        // 输入框聚焦效果
        const inputs = document.querySelectorAll('.form-control');
        inputs.forEach(input => {
            input.addEventListener('focus', function() {
                this.parentElement.parentElement.classList.add('focused');
            });
            
            input.addEventListener('blur', function() {
                this.parentElement.parentElement.classList.remove('focused');
            });
        });
    </script>
</body>
</html>